<template>
  <div class="login_phone">
    <el-form
      ref="formRef"
      :model="userInfo"
      :rules="phoneRules"
      class="demo-ruleForm"
      :size="formSize"
      label-position="right"
      label-width="70px"
    >
      <el-form-item label="手机" prop="phone">
        <el-input v-model="userInfo.phone" />
      </el-form-item>
      <div class="code">
        <el-form-item label="验证码" prop="code">
          <el-input v-model="userInfo.code" />
        </el-form-item>
        <el-button type="primary">发送</el-button>
      </div>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { ElForm } from 'element-plus';
import { reactive, ref, defineExpose } from 'vue';
import { phoneRules } from '../config';
let userInfo = reactive({
  phone: '',
  code: ''
});
let formRef = ref<InstanceType<typeof ElForm>>();
const loginByPhone = () => {
  formRef.value?.validate((valid) => {
    if (valid) {
      console.log('验证通过');
    }
  });
};
defineExpose({
  loginByPhone
});
</script>
<style lang="less" scoped>
.login_phone {
  .code {
    display: flex;
    .el-button {
      margin-left: 5px;
    }
  }
}
</style>
